package com.mall.users.service;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.model.domain.UmsMenu;
import com.mall.model.domain.UmsRole;
import com.mall.model.domain.UmsRoleMenuRelation;
import com.mall.users.mapper.UmsRoleMenuRelationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UmsRoleMenuRelationService {


    @Autowired
    private UmsRoleMenuRelationMapper umsRoleMenuRelationMapper;


    /**
     * 根据角色id查询菜单id
     * @param roleIds
     * @return
     */
    public List<Long> findByRoleIds(List<Long> roleIds) {
        return umsRoleMenuRelationMapper.selectByRoleIds(roleIds);
    }

    /**
     * 根据角色id删除与菜单关系
     * @param roleIds
     * @return
     */
    public void deleteByRoleIds(List<Long> roleIds) {
        umsRoleMenuRelationMapper.deleteByRoleIds(roleIds);
    }

    /**
     * 保存角色与菜单关系
     * @param roleId
     * @param menuIds
     */
    public void save(Long roleId, List<Long> menuIds) {
        umsRoleMenuRelationMapper.save(roleId, menuIds);
    }
}
